package ControlLayer;
import ModelLayer.*;

/**
 * Write a description of class AddressBookCtr here.
 * 
 * @author (Yaxuan) 
 * @version (05.11.2012)
 */
public class AddressBookCtr
{
    private AddressBook addressBook;

    public AddressBookCtr()
    {
        addressBook = AddressBook.getInstance();
    }
    
    public Person getPerson(int id) 
    {
        Person person = addressBook.getPerson(id);
        return person;

    }

    public void createPerson(int id, String name, String address, long postalCode, String city, long phoneNr)
    {
        Person person;
        person = new Person(id, name, address, postalCode, city, phoneNr);
        addressBook.addPerson(person);
    }

    public void removePerson(int id) 
    {
        addressBook.removePerson(id);
    }

    public void updatePerson(int choise, int id, String value) 
    {
        addressBook.updatePerson(choise, id, value);
    }

    public void printPerson(int id)
    {
        Person person = getPerson(id);
        if (person != null)
            person.print();
    }

    public void listAllPersons()
    {
        addressBook.printAddressBook();
    }

    public void printPersonLoanList(int personID)
    {
        getPerson(personID).printAllLoans();
    }

}
